set nocompatible              
filetype off       


" 设置包括 vundle 和初始化相关的 runtimepath
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" 另一种选择, 指定一个 vundle 安装插件的路径
"call vundle#begin('~/some/path/here')
" 让 vundle 管理插件版本,必须
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
"Plugin 'vim-scripts/taglist.vim'
" Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdcommenter'
"Plugin 'w0rp/ale'
"{
"     所有的插件安装配置都必须在此范围内配置
"}

" 所有插件需要在下面这行之前配置
call vundle#end()            " 必须
filetype plugin indent on    " 必须 加载vim自带和插件相应的语法和文件类型相关脚本
" 忽视插件改变缩进,可以使用以下替代:
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/completee-dict'

set nu 


syntax on 

set shiftwidth=4 

set softtabstop=4 

set tabstop=4 

set expandtab

"python自动缩进
set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf pyhton
set autoindent " same level indent
set smartindent " next level indent
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4

inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {}<ESC>i
inoremap < <><ESC>i
inoremap ' ''<ESC>i
inoremap " ""<ESC>i


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"键盘命令
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
":nmap <silent> <F9> <ESC>:Tlist<RETURN>
"shift tab pages
"map <S-Left> :tabp<CR>
"map <S-Right> :tabn<CR>
"map! <C-Z> <Esc>zzi
"map! <C-O> <C-Y>,
map <C-A> ggVG$"+y
"map <Esc><Esc> :w<CR>
"map <F12> gg=G
"map <C-w> <C-w>w
"imap <C-k> <C-y>,
"imap <C-t> <C-q><TAB>
"imap <C-j> <ESC>
" 选中状态下 Ctrl+c 复制
map <C-c> yyi
imap <C-c> <Esc>yyi
map <C-v> pi
imap <C-v> <Esc>pi
imap <F4> <Esc>\nt
map <F4> \nt
imap <F5>  <Esc>\cii
map <F5>  \cii
map <C-d> ddi
imap <C-d> <Esc>ddi
map <C-z> ui
imap <C-z> <Esc>ui

"set mouse=v
"set clipboard=unnamed
"去空行
""nnoremap <F2> :g/^\s*$/d<CR>
"比较文件
""nnoremap <C-F2> :vert diffsplit
"nnoremap <Leader>fu :CtrlPFunky<Cr>
"nnoremap <C-n> :CtrlPFunky<Cr>
"列出当前目录文件
""map <F3> :NERDTreeToggle<CR>
""imap <F3> <ESC> :NERDTreeToggle<CR>
"打开树状文件目录
""map <C-F3> \be
"":autocmd BufRead,BufNewFile *.dot map <F5> :w<CR>:!dot -Tjpg -o %<.jpg % && eog %<.jpg  <CR><CR> && exec "redr!"



"python 代码自动补全

"wget https://github.com/rkulla/pydiction/archive/master.zip
"unzip -q master
"mv pydiction-master pydiction
"mkdir -p ~/.vim/tools/pydiction
"cp -r pydiction/after ~/.vim
"cp pydiction/complete-dict ~/.vim/tools/pydiction
"vim ~/.vimrc
"filetype plugin on
"let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
"let g:pydiction_menu_height = 3''

cd ~/.vim/bundle
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
let g:pydiction_menu_height = 3




"代码动态检查（ale）
"let g:ale_lint_on_text_changed       = 'normal'                     " 代码更改后启动检查 
"let g:ale_lint_on_insert_leave       = 1                            " 退出插入模式即检查
"let g:ale_sign_column_always         = 1                            " 总是显示动态检查结果
"let g:ale_sign_error                 = '>>'                         " error 告警符号
"let g:ale_sign_warning               = '--'                         " warning 告警符号
"let g:ale_echo_msg_error_str         = 'E'                          " 错误显示字符
"let g:ale_echo_msg_warning_str       = 'W'                          " 警告显示字符
"let g:ale_echo_msg_format            = '[%linter%] %s [%severity%]' " 告警显示格式

" C 语言配置检查参数
" let g:ale_c_gcc_options              = '-Wall -Werror -O2 -std=c11'
" let g:ale_c_clang_options            = '-Wall -Werror -O2 -std=c11'
" let g:ale_c_cppcheck_options         = ''
" C++ 配置检查参数
" let g:ale_cpp_gcc_options            = '-Wall -Werror -O2 -std=c++14'
" let g:ale_cpp_clang_options          = '-Wall -Werror -O2 -std=c++14'
" let g:ale_cpp_cppcheck_options       = ''

"使用clang对c和c++进行语法检查，对python使用pylint进行语法检查
"  let g:ale_linters = {
"  \   'c++': ['clang', 'gcc'],
"  \   'c': ['clang', 'gcc'],
"  \   'python': ['pylint'],
"  \}
" <F9> 触发/关闭代码动态检查
"  map <F9> :ALEToggle<CR>
"普通模式下，ak 前往上一个错误或警告，aj 前往下一个错误或警告                                                                                                                                                    
"  nmap ak <Plug>(ale_previous_wrap)
"  nmap aj <Plug>(ale_next_wrap)
" ad 查看错误或警告的详细信息
"  nmap ad :ALEDetail<CR>





"快速添加/删除注释（nerdcommenter）
let g:NERDCustomDelimiters       = {'c': {'left': '/*', 'right': '*/'}} " C 语言注释符号
let g:NERDCommentEmptyLines      = 1                                    " 允许空行注释
let g:NERDTrimTrailingWhitespace = 1                                    " 取消注释时删除行尾空格
let g:NERDToggleCheckAllLines    = 1                                    " 检查选中的行操作是否成功



"自动补全（YouCompleteMe）
" let g:ycm_key_list_select_com let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
" let g:ycm_min_num_of_chars_for_completion               = 2 " 输入第 2 个字符开始补全
" let g:ycm_seed_identifiers_with_syntax                  = 1 " 语法关键字补全
" let g:ycm_complete_in_comments                          = 1 " 在注释中也可以补全
" let g:ycm_complete_in_strings                           = 1 " 在字符串输入中也能补全
" let g:ycm_collect_identifiers_from_tag_files            = 1 " 使用 ctags 生成的 tags 文件
" let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
" let g:ycm_cache_omnifunc                                = 0 " 每次重新生成匹配项，禁止缓存匹配项
" let g:ycm_use_ultisnips_completer                       = 0 " 不查询 ultisnips 提供的代码模板补全，如果需要，设置成 1 即可
" let g:ycm_show_diagnostics_ui                           = 0 " 禁用语法检查
" let g:ycm_key_list_select_completion   = ['<Down>']   " 选择下一条补全，Default: ['<TAB>', '<Down>']
" let g:ycm_key_list_previous_completion = ['<Up>']     " 选择上一条补全，Default: ['<S-TAB>', '<Up>']
" let g:ycm_key_list_stop_completion     = ['<Enter>']  " 中止此次补全，Default: ['<C-y>']





"标签列表（taglist.vim）
let Tlist_Show_One_File           = 1    " 只显示当前文件的tags
let Tlist_GainFocus_On_ToggleOpen = 1    " 打开 Tlist 窗口时，光标跳到 Tlist 窗口
let Tlist_Exit_OnlyWindow         = 1    " 如果 Tlist 窗口是最后一个窗口则退出 Vim
let Tlist_Use_Left_Window         = 1    " 在左侧窗口中显示
let Tlist_File_Fold_Auto_Close    = 1    " 自动折叠
let Tlist_Auto_Update             = 1    " 自动更新

" <leader>tl 打开 Tlist 窗口，在左侧栏显示
map <leader>tl :TlistToggle<CR>



"标签导航 （tagbar）

let g:tagbar_ctags_bin = 'ctags' " tagbar 依赖 ctags 插件
let g:tagbar_width     = 30      " 设置 tagbar 的宽度为 30 列，默认 40 列
let g:tagbar_autofocus = 1       " 打开 tagbar 时光标在 tagbar 页面内，默认在 vim 打开的文件内
let g:tagbar_left      = 1       " 让 tagbar 在页面左侧显示，默认右边
"let g:tagbar_sort      = 0       " 标签不排序，默认排序

" <leader>tb 打开 tagbar 窗口，在左侧栏显示
map <leader>tb :TagbarToggle<CR>


"主题（solarized）
let g:solarized_termtrans  = 1        " 使用 termnal 背景
let g:solarized_visibility = "high"   " 使用 :set list 显示特殊字符时的高亮级别

" GUI 模式浅色背景，终端模式深色背景
if has('gui_running')
    set background=light
else
    set background=dark
endif
"           
"           " 主题设置为 solarized
colorscheme solarized


"目录树（NERDTree）
let NERDTreeHighlightCursorline = 1       " 高亮当前行
let NERDTreeShowLineNumbers     = 1       " 显示行号
" 忽略列表中的文件
let NERDTreeIgnore = [ '\.pyc$', '\.pyo$', '\.obj$', '\.o$', '\.egg$', '^\.git$', '^\.repo$', '^\.svn$', '^\.hg$' ]
" 启动 vim 时打开 NERDTree
" autocmd vimenter * NERDTree
" 当打开 VIM，没有指定文件时和打开一个目录时，打开 NERDTree
"autocmd StdinReadPre * let s:std_in = 1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" 关闭 NERDTree，当没有文件打开的时候
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | end

" <leader>nt 打开 nerdtree 窗口，在左侧栏显示
map <leader>nt :NERDTreeToggle<CR>
" <leader>tc 关闭当前的 tab
map <leader>tc :tabc<CR>
" <leader>to 关闭所有其他的 tab
map <leader>to :tabo<CR>
" <leader>ts 查看所有打开的 tab
map <leader>ts :tabs<CR>
" <leader>tp 前一个 tab
map <leader>tp :tabp<CR>
" <leader>tn 后一个 tab
map <leader>tn :tabn<CR>
